namespace cpp mp2

struct NodeInfo
{
	1:i32 id;
	2:i32 port;
}

struct FileMap
{
	1:string name;
	2:binary data;
}

struct GetFileReturn
{
	1:binary data;
	2:string output;
}

service NodeService {
	/* Documentation for the following functions can
	 * be found in NodeService_server.h
     */
	void setNodeInfo(1:NodeInfo info);
	void setChordInfo(1:i32 bits);
	void setIntroducer(1:NodeInfo info);

	void alertOfNewNode(1:NodeInfo info);

	void setPredecessor(1:NodeInfo info);
	void setSuccessor(1:NodeInfo info);

	NodeInfo getPredecessor();
	NodeInfo getSuccessor();

	NodeInfo getFingerPointer(1:i32 id);
	NodeInfo getNewNodeSuccessor(1:i32 id);

	GetFileReturn getFile(1:string filename);
	string addFile(1:binary data, 2:string filename);
	string deleteFile(1:string filename);
	NodeInfo getFileLocation(1:string filename);
	i32 getHash(1:string filename);

	void addNode(1:NodeInfo info);
	NodeInfo getNode(1:i32 id);

	string getTable(1:NodeInfo info);
	list<NodeInfo> getFingerTable(1:NodeInfo info);
	map<i32,FileMap> getKeys(1:NodeInfo info);

	void updateFingerTable();

	void stabilize();

	void listNodes(1:i32 n);

	void askNeighborsForFiles();
}